<html>
<head><meta charset="utf-8"><title>futures crate(s) · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html">futures crate(s)</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="167476484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167476484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167476484">(Jun 06 2019 at 12:25)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="203289">@boats</span>, <span class="user-mention" data-user-id="127859">@Taylor Cramer</span>  --</p>
<p>One of the questions that I don't have a good handle on is the futures crate. Looking at the <a href="https://github.com/rust-lang-nursery/futures-rs" target="_blank" title="https://github.com/rust-lang-nursery/futures-rs">rust-lang-nursery/futures-rs</a> crate, I see a lot of "subcrates". Is there some consensus about the relative importance of these various features? Is the plan to move some/all of this into libstd at some point, once it's had more time to bake?</p>



<a name="167490425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167490425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167490425">(Jun 06 2019 at 15:10)</a>:</h4>
<p>There's not a clear consensus. My understanding of the current plan is that some time between Future being stabilized and async/await being stabilized, we will release an <code>0.3</code> of the crates which will be substantially similar to the current API.</p>



<a name="167490453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167490453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167490453">(Jun 06 2019 at 15:10)</a>:</h4>
<p>We've discussed a 1.0 version at the all hands, but there were several outstanding issues that made that seem more difficult to produce</p>



<a name="167490493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167490493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167490493">(Jun 06 2019 at 15:11)</a>:</h4>
<p>In the long term, there's a general sense that we'd like core abstractions like stream, asyncread, asyncwrite to be in std, but its still very unclear and up in the air</p>



<a name="167491567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167491567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Gilcher <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167491567">(Jun 06 2019 at 15:22)</a>:</h4>
<p>Would it be possible to extract an uncontroversial subset and release that as 1.0?</p>



<a name="167492157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167492157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167492157">(Jun 06 2019 at 15:28)</a>:</h4>
<p>I wanted to look into doing that but I think it will have to be delayed until after async/await is stable</p>



<a name="167501643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167501643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167501643">(Jun 06 2019 at 17:19)</a>:</h4>
<p><span class="user-mention" data-user-id="215333">@Florian Gilcher</span> unfortunately the uncontroversial subset does not include Stream</p>



<a name="167501724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167501724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167501724">(Jun 06 2019 at 17:20)</a>:</h4>
<p><code>AsyncRead</code>/<code>AsyncWrite</code> IMO are the most "obvious"ly correct, but even they have points of disagreement that folks have argued over.</p>



<a name="167501758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167501758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167501758">(Jun 06 2019 at 17:21)</a>:</h4>
<p><code>futures-core</code> and <code>futures-io</code>are meant to represent a subset that is stable enough for folks to rely on in public API boundaries</p>



<a name="167501843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167501843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167501843">(Jun 06 2019 at 17:22)</a>:</h4>
<p>everything else is intended to be left as utilities/implementation details that can evolve freely over time as they grow to better fit the needs of users.</p>



<a name="167506050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167506050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167506050">(Jun 06 2019 at 18:05)</a>:</h4>
<p>I would be a concerned with a development of having too many AsyncX traits</p>



<a name="167506075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167506075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167506075">(Jun 06 2019 at 18:05)</a>:</h4>
<p>that would presumably cause a lot of code duplication and be unfortunate from an effect system POV</p>



<a name="167508021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167508021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167508021">(Jun 06 2019 at 18:26)</a>:</h4>
<p><span class="user-mention" data-user-id="126931">@centril</span> I don't think that's avoidable</p>



<a name="167508051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167508051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167508051">(Jun 06 2019 at 18:26)</a>:</h4>
<p>elaborate?</p>



<a name="167508053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167508053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167508053">(Jun 06 2019 at 18:26)</a>:</h4>
<p>Like, this is the "what color is your function" problem in its purest form</p>



<a name="167508076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167508076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167508076">(Jun 06 2019 at 18:26)</a>:</h4>
<p>This problem has a known solution: Monads or effect systems.</p>



<a name="167508098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167508098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167508098">(Jun 06 2019 at 18:27)</a>:</h4>
<p>We cannot do the former; we can do the latter.</p>



<a name="167508108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167508108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167508108">(Jun 06 2019 at 18:27)</a>:</h4>
<p>Neither of those solve this problem, and there's tons of existing literature into why</p>



<a name="167508206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167508206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167508206">(Jun 06 2019 at 18:28)</a>:</h4>
<p>but I'd be happy to discuss w/ you why and what an "async trait"-like effects system might look like, and why I think it's unlikely to pan out, at least anytime in the near future</p>



<a name="167508222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167508222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167508222">(Jun 06 2019 at 18:28)</a>:</h4>
<p>Not the literature I've read (e.g. Frank, Idris's algebraic effects, etc.) but I'm happy to discuss it</p>



<a name="167508225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167508225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167508225">(Jun 06 2019 at 18:28)</a>:</h4>
<p>I'm not completely defeatist on the idea, but I think it's very far from where we are today</p>



<a name="167508271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167508271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167508271">(Jun 06 2019 at 18:29)</a>:</h4>
<p><span class="user-mention" data-user-id="127859">@Taylor Cramer</span> aside: up for pre-triage mtg?</p>



<a name="167508705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167508705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167508705">(Jun 06 2019 at 18:33)</a>:</h4>
<p><span class="user-mention" data-user-id="126931">@centril</span> yeah, it doesn't look like I'm getting kicked out of my room yet</p>



<a name="167508716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167508716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167508716">(Jun 06 2019 at 18:33)</a>:</h4>
<p>often I can't get a room :(</p>



<a name="167508720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167508720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167508720">(Jun 06 2019 at 18:33)</a>:</h4>
<p>neat</p>



<a name="167509919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167509919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Gilcher <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167509919">(Jun 06 2019 at 18:45)</a>:</h4>
<p><span class="user-mention" data-user-id="127859">@Taylor Cramer</span> I don't see why we absolutely need <code>Stream</code>, TBH</p>



<a name="167509990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167509990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Gilcher <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167509990">(Jun 06 2019 at 18:45)</a>:</h4>
<p>From my point of view, Stream as a stable and all-encompassing abstraction takes time, but for any subset of users needs, either using a concrete channel implementation or an ad-hoc library trait will do.</p>



<a name="167511950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167511950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167511950">(Jun 06 2019 at 19:03)</a>:</h4>
<p><span class="user-mention" data-user-id="215333">@Florian Gilcher</span> interesting. I think it's necessary for the same reasons that <code>Iterator</code> is necessary, but maybe you're considering a more specific use-case than the ones I have in mind</p>



<a name="167544269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167544269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167544269">(Jun 07 2019 at 03:53)</a>:</h4>
<p>I think I already tried to start a few discussions around this which never got traction. But here’s my opinion again: </p>
<p>I think neither Streams nor the AsyncXyz things should be stabilized right now, and until someone can paint a clear path forward for a reasonable integration with futures. Up to now only Nemo157 could do that partially, and even they weren’t sure if it would really work out.  Up to that point even the current prominence of those types in crates like Runtime feels unfortunate. I wouldn’t want to see a 3 color function world in Rust. And neither people building on top of abstractions which get canned later on.</p>



<a name="167558922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167558922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Gilcher <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167558922">(Jun 07 2019 at 08:45)</a>:</h4>
<p><span class="user-mention" data-user-id="204219">@Matthias247</span> how do you want to stop people from building on top?</p>



<a name="167558978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167558978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Gilcher <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167558978">(Jun 07 2019 at 08:46)</a>:</h4>
<p>Like, honestly, people are waiting for this for years now, they will either take what we give or build their own.</p>



<a name="167559046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167559046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Gilcher <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167559046">(Jun 07 2019 at 08:47)</a>:</h4>
<p><span class="user-mention" data-user-id="127859">@Taylor Cramer</span> you mean as adapters? I don't think they fill the same niche as Iterator, especially not in a sense that they need to be available as a finished interface from the get-go</p>



<a name="167560245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167560245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Gilcher <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167560245">(Jun 07 2019 at 09:05)</a>:</h4>
<p>Like, I appreciate that they should be present, but useful applications of considerable size can be written without, which gives a bit of leeway to not stabilising them.</p>



<a name="167566553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167566553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167566553">(Jun 07 2019 at 10:55)</a>:</h4>
<p><span class="user-mention" data-user-id="215333">@Florian Gilcher</span> no one wants to include these things in the MVP</p>



<a name="167566727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167566727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167566727">(Jun 07 2019 at 10:58)</a>:</h4>
<p>I mean I guess youre talking about leaving stream out of a 1.0 version of the futures crate</p>



<a name="167590290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167590290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167590290">(Jun 07 2019 at 16:12)</a>:</h4>
<p><span class="user-mention" data-user-id="215333">@Florian Gilcher</span> You can’t stop but you can discourage. E.g. by leavings things out of stabilization as proposed. And by at least communicating that this is an open area, and investing some work in it (experimenting and then proposing a path forward). Right now the official communication sounds like: Stream is the way to go, and we might make it somehow work with Generators. Due to that projects like runtime and go are picking things up as their core abstraction.</p>



<a name="167600601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167600601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167600601">(Jun 07 2019 at 18:23)</a>:</h4>
<p>I don't know what a 1.0 version of the futures crate would include if not <code>Stream</code>. It seems like it'd just be what's in std, which is the only "true" 1.0 in my mind</p>



<a name="167706765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167706765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Gilcher <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167706765">(Jun 09 2019 at 16:30)</a>:</h4>
<p><span class="user-mention" data-user-id="203289">@boats</span> my initial question was if there's a subset of the futures crate that _is_ ready for 1.0 and it has slowly drifted that people seem to feel like such a subset is not useful.</p>



<a name="167706792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167706792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Gilcher <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167706792">(Jun 09 2019 at 16:31)</a>:</h4>
<p><span class="user-mention" data-user-id="127859">@Taylor Cramer</span> futures combinators for example, potentially asyncread/write to build protocols on a more abstract fashion then reading sockets directly.</p>



<a name="167761727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167761727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> stjepang <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167761727">(Jun 10 2019 at 14:05)</a>:</h4>
<p>I wonder if <code>AsyncRead</code>/<code>AsyncWrite</code>/<code>Stream</code> should use proper <code>async fn foo</code> instead of <code>fn poll_foo</code> (once async trait methods become possible). What do you think about renaming current <code>AsyncRead</code>/<code>AsyncWrite</code> to <code>PollRead</code>/<code>PollWrite</code> instead?</p>



<a name="167761745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167761745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> stjepang <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167761745">(Jun 10 2019 at 14:05)</a>:</h4>
<p>So we'd have something like:</p>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">PollRead</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">poll_read</span><span class="p">(</span><span class="w"></span>
<span class="w">        </span><span class="bp">self</span>: <span class="nc">Pin</span><span class="o">&lt;&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">Self</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">cx</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="n">Context</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">buf</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="p">[</span><span class="kt">u8</span><span class="p">]</span><span class="w"></span>
<span class="w">    </span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Poll</span><span class="o">&lt;</span><span class="nb">Result</span><span class="o">&lt;</span><span class="kt">usize</span><span class="p">,</span><span class="w"> </span><span class="n">Error</span><span class="o">&gt;&gt;</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="167761769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167761769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> stjepang <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167761769">(Jun 10 2019 at 14:05)</a>:</h4>
<p>Then, once async trait methods become possible, we can add:</p>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">AsyncRead</span>: <span class="nc">PollRead</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">async</span><span class="w"> </span><span class="k">fn</span> <span class="nf">read</span><span class="p">(</span><span class="n">buf</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="p">[</span><span class="kt">u8</span><span class="p">])</span><span class="w"> </span>-&gt; <span class="nc">Poll</span><span class="o">&lt;</span><span class="nb">Result</span><span class="o">&lt;</span><span class="kt">usize</span><span class="p">,</span><span class="w"> </span><span class="n">Error</span><span class="o">&gt;&gt;</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="167761889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167761889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> stjepang <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167761889">(Jun 10 2019 at 14:06)</a>:</h4>
<p>Finally, we deprecate polling traits in favor of the new traits using <code>async fn</code> and add the following blanket impl.</p>
<div class="codehilite"><pre><span></span><span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nc">PollRead</span><span class="o">&gt;</span><span class="w"> </span><span class="n">AsyncRead</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">async</span><span class="w"> </span><span class="k">fn</span> <span class="nf">read</span><span class="p">(</span><span class="n">buf</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="p">[</span><span class="kt">u8</span><span class="p">])</span><span class="w"> </span>-&gt; <span class="nb">Result</span><span class="o">&lt;</span><span class="kt">usize</span><span class="p">,</span><span class="w"> </span><span class="n">Error</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">future</span>::<span class="n">poll_fn</span><span class="p">(</span><span class="o">|</span><span class="n">cx</span><span class="o">|</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">poll_read</span><span class="p">(</span><span class="n">cx</span><span class="p">,</span><span class="w"> </span><span class="n">buf</span><span class="p">)).</span><span class="n">await</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>This way, libraries using <code>PollRead</code> can switch to <code>AsyncRead</code> without breaking backwards compatibility.</p>



<a name="167762041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167762041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> stjepang <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167762041">(Jun 10 2019 at 14:08)</a>:</h4>
<p>The problem with <code>poll_foo</code> methods is that they don't return futures. It is (in a philosophical sense) <em>wrong</em> for <code>File</code> to have <code>poll_read()</code> method because, well, files are not futures. However, operations on files (like read or write) are futures.</p>



<a name="167762200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167762200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> stjepang <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167762200">(Jun 10 2019 at 14:10)</a>:</h4>
<p>This especially becomes a problem when asynchronous operations need to keep some state. For example, with <code>poll_read</code>, async read operations cannot keep their own state. And if there is any state inside an async read operation, then it has to be embedded into the <code>File</code> struct.</p>



<a name="167762407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167762407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> stjepang <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167762407">(Jun 10 2019 at 14:12)</a>:</h4>
<p>But even that's fraught with problems because then there is no way to "cancel" async operations with <code>poll_read()</code>. If you begin a read operation by calling <code>poll_read()</code> and then timeout on it, you can't drop the future to cancel it because there isn't one! That means the next read operation will try to pick up the state of the previous <code>poll_read()</code> invocation, which isn't right.</p>



<a name="167762533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167762533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> stjepang <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167762533">(Jun 10 2019 at 14:14)</a>:</h4>
<p>All those problems make me believe <code>poll_foo</code> methods should only belong to real futures (i.e. async operations), and <em>not</em> to objects that can be operated on asynchronously (i.e. start async operations).</p>



<a name="167780518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167780518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nemo157 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167780518">(Jun 10 2019 at 17:56)</a>:</h4>
<p><span class="user-mention" data-user-id="128448">@stjepang</span> main discussion of that idea is at <a href="https://github.com/rust-lang-nursery/futures-rs/issues/1365" target="_blank" title="https://github.com/rust-lang-nursery/futures-rs/issues/1365">https://github.com/rust-lang-nursery/futures-rs/issues/1365</a></p>



<a name="167780770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167780770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nemo157 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167780770">(Jun 10 2019 at 17:59)</a>:</h4>
<p>the major issue that cramertj mentions is that <code>async fn read</code> in a trait is actually sugar for an associated type + function (well, almost certainly going to be, once it's defined), once you have that associated type on the trait how do you deal with <code>dyn AsyncRead</code>?</p>



<a name="167784206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167784206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167784206">(Jun 10 2019 at 18:36)</a>:</h4>
<p>the alternative solution is to have it be a dynamically-dispatched future of some kind, but it's unclear exactly how that would work</p>



<a name="167784292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167784292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167784292">(Jun 10 2019 at 18:37)</a>:</h4>
<p>one proposal that i'd been playing around with was a kind of automatic version of what we did for <code>Waker</code>, which is to offer by-value DSTs with a fixed "max size" (in the case of waker, the size is "one pointer width")</p>



<a name="167784449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167784449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167784449">(Jun 10 2019 at 18:38)</a>:</h4>
<p>we could do something sorta clever like making the object returned the size of all the arguments to the function + alignment so that you could store them all in a struct and return that type to prevent having to heap-allocate for all the existing impls while retaining object safety</p>



<a name="167784465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167784465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167784465">(Jun 10 2019 at 18:38)</a>:</h4>
<p>it's <em>really</em> complicated though and requires a whole field of language functionality we don't have today</p>



<a name="167784700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167784700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167784700">(Jun 10 2019 at 18:41)</a>:</h4>
<p>e.g.:</p>
<div class="codehilite"><pre><span></span>trait AsyncRead {
    async fn read(&amp;mut self, buf: &amp;mut [u8]) -&gt; Result&lt;usize, io::Error&gt;;
}
</pre></div>


<p>would desugar into something like this:</p>
<div class="codehilite"><pre><span></span>trait AsyncRead {
    fn read&lt;&#39;a&gt;(&amp;&#39;a mut self, buf: &amp;&#39;a mut [u8]) -&gt; dyn&lt;sizeof(usize) * 2&gt; Future&lt;Output = Result&lt;...&gt;&gt; + &#39;a;
}
</pre></div>



<a name="167784803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167784803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167784803">(Jun 10 2019 at 18:42)</a>:</h4>
<p>where <code>dyn&lt;NUM&gt; Trait</code> is some by-value dyn trait with an upper size bound of <code>NUM</code></p>



<a name="167784836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167784836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167784836">(Jun 10 2019 at 18:42)</a>:</h4>
<p>and implementing it with an <code>async fn</code> whose body was too big would require writing <code>async(Box:new)</code> or something</p>



<a name="167785516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167785516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> stjepang <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167785516">(Jun 10 2019 at 18:50)</a>:</h4>
<blockquote>
<p>the major issue that cramertj mentions is that <code>async fn read</code> in a trait is actually sugar for an associated type + function (well, almost certainly going to be, once it's defined), once you have that associated type on the trait how do you deal with <code>dyn AsyncRead</code>?</p>
</blockquote>
<p>Do we need <code>dyn AsyncRead</code>? Can we just make traits with <code>async fn</code>s not object-safe?</p>



<a name="167785788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167785788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167785788">(Jun 10 2019 at 18:53)</a>:</h4>
<p><span class="user-mention" data-user-id="128448">@stjepang</span> yes, <code>dyn AsyncRead</code> is critically important</p>



<a name="167785935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167785935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167785935">(Jun 10 2019 at 18:55)</a>:</h4>
<blockquote>
<p>can we make traits with <code>async fn</code>s not object-safe?</p>
</blockquote>
<p>Yes, but people will continue to hack around them and not use them if that's the case. I'm not opposed to starting here necessarily, but it's not a generally applicable solution.</p>



<a name="167786558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167786558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167786558">(Jun 10 2019 at 19:02)</a>:</h4>
<blockquote>
<p><code>dyn AsyncRead</code> is critically important</p>
</blockquote>
<p>As a curious bystander, why is that?</p>



<a name="167786931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167786931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167786931">(Jun 10 2019 at 19:07)</a>:</h4>
<p><span class="user-mention" data-user-id="116155">@Jake Goulding</span> it's a core point over which libraries and other tools allow abstraction of underlying interfaces (notably TCP), and making all of the relevant functions generic over those parameters is either not an option in some places due to heterogeneous collections, or it would cause an incredibly large amount of code bloat</p>



<a name="167787022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167787022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167787022">(Jun 10 2019 at 19:08)</a>:</h4>
<p>(note that all the same comments apply to <code>Stream</code>, if you viewed it as <code>async fn next(&amp;mut self) -&gt; Option&lt;Self::Item&gt;;</code>)</p>



<a name="167787143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167787143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167787143">(Jun 10 2019 at 19:09)</a>:</h4>
<p>Why is this code bloat more of a problem compared to plain-old <code>Read</code> or <code>Iterator</code> (which I use as my sync version of <code>Stream</code>)?</p>



<a name="167787636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167787636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> stjepang <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167787636">(Jun 10 2019 at 19:16)</a>:</h4>
<p><span class="user-mention" data-user-id="127859">@Taylor Cramer</span> I'm curious too - I've never seen <code>dyn Iterator</code>, <code>dyn Read</code>, or <code>dyn Write</code> before. Are async versions really used with dynamic dispatch?</p>



<a name="167787710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167787710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167787710">(Jun 10 2019 at 19:17)</a>:</h4>
<p>I've used all of those a bunch</p>



<a name="167787726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167787726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167787726">(Jun 10 2019 at 19:17)</a>:</h4>
<p><span class="user-mention" data-user-id="116155">@Jake Goulding</span> it isn't, but the same comments apply to <code>Read</code> and <code>Iterator</code></p>



<a name="167787781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167787781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167787781">(Jun 10 2019 at 19:18)</a>:</h4>
<p>those are used w/ dynamic dispatch very often</p>



<a name="167789428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167789428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167789428">(Jun 10 2019 at 19:38)</a>:</h4>
<p>Hmm. We must experience drastically different types of code, I suppose; I find dynamic dispatch relatively uncommon.</p>



<a name="167789470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167789470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167789470">(Jun 10 2019 at 19:39)</a>:</h4>
<p>However, it wouldn't surprise me if most functions took the generic and then certain classes of callers used the trait object</p>



<a name="167789777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167789777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167789777">(Jun 10 2019 at 19:42)</a>:</h4>
<p>a search for <code>&amp;mut Read</code> on github turns up a few thousand results, but I don't know how large that is by percentage</p>



<a name="167789778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167789778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167789778">(Jun 10 2019 at 19:42)</a>:</h4>
<p><a href="https://github.com/search?q=%22%26mut+Read%22+language%3ARust&amp;type=Code" target="_blank" title="https://github.com/search?q=%22%26mut+Read%22+language%3ARust&amp;type=Code">https://github.com/search?q=%22%26mut+Read%22+language%3ARust&amp;type=Code</a></p>



<a name="167789841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167789841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167789841">(Jun 10 2019 at 19:43)</a>:</h4>
<p><code>Box&lt;Read&gt;</code> + <code>Box&lt;dyn Read&gt;</code> is only about 200</p>



<a name="167789867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167789867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167789867">(Jun 10 2019 at 19:43)</a>:</h4>
<p><code>Box&lt;Iterator</code> also gives a few thousand</p>



<a name="167789920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167789920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167789920">(Jun 10 2019 at 19:44)</a>:</h4>
<p><code>&amp;mut Iterator</code> is ~2k</p>



<a name="167795136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795136">(Jun 10 2019 at 20:48)</a>:</h4>
<p>We encourage people to take the generics (e.g. <a href="https://rust-lang-nursery.github.io/api-guidelines/interoperability.html#generic-readerwriter-functions-take-r-read-and-w-write-by-value-c-rw-value" target="_blank" title="https://rust-lang-nursery.github.io/api-guidelines/interoperability.html#generic-readerwriter-functions-take-r-read-and-w-write-by-value-c-rw-value">https://rust-lang-nursery.github.io/api-guidelines/interoperability.html#generic-readerwriter-functions-take-r-read-and-w-write-by-value-c-rw-value</a>) because it works for both cases.</p>



<a name="167795174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795174">(Jun 10 2019 at 20:49)</a>:</h4>
<p>it also generates a heck of a lot more code ;)</p>



<a name="167795195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795195">(Jun 10 2019 at 20:49)</a>:</h4>
<p>and doesn't work for heterogeneous collections</p>



<a name="167795288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795288">(Jun 10 2019 at 20:50)</a>:</h4>
<p>hm, it should work with heterogeneous collections?</p>



<a name="167795299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795299">(Jun 10 2019 at 20:50)</a>:</h4>
<p>I've personally found trait objects to be extremely useful and would be concerned if we didn't have a story for them</p>



<a name="167795333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795333">(Jun 10 2019 at 20:50)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> perhaps what I said was unclear: e.g. <code>HashMap&lt;u32, Box&lt;dyn Read&gt;&gt;</code> won't work with generics</p>



<a name="167795347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795347">(Jun 10 2019 at 20:51)</a>:</h4>
<p>I dunno about "a heck of a lot" because I simply haven't done that investigation; can you point to any info I can read to have a sense of the magnitude?</p>



<a name="167795348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795348">(Jun 10 2019 at 20:51)</a>:</h4>
<p>it only works due to trait objects</p>



<a name="167795363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795363">(Jun 10 2019 at 20:51)</a>:</h4>
<p>Mostly I know about the format machinery, where the codegen was indeed too much</p>



<a name="167795382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795382">(Jun 10 2019 at 20:51)</a>:</h4>
<p><span class="user-mention" data-user-id="116155">@Jake Goulding</span> I've personally changed a few functions in fuchsia to use trait objects rather than generics and dropped compilation times and binary size by more than 30%</p>



<a name="167795432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795432">(Jun 10 2019 at 20:52)</a>:</h4>
<p><code>Box&lt;dyn Read&gt;</code> implements Read though so I'd sort of expect it to work...?</p>



<a name="167795436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795436">(Jun 10 2019 at 20:52)</a>:</h4>
<p>as far as more holistic samples, I know <span class="user-mention" data-user-id="116015">@Alex Crichton</span> has done some in the past</p>



<a name="167795446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795446">(Jun 10 2019 at 20:52)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> to be clear, the <code>Box&lt;dyn Read&gt;</code> is exactly the piece I'm talking about</p>



<a name="167795452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795452">(Jun 10 2019 at 20:52)</a>:</h4>
<p>you can't write <code>HashMap&lt;u32, Box&lt;impl Read&gt;&gt;</code></p>



<a name="167795462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795462">(Jun 10 2019 at 20:52)</a>:</h4>
<p>and store multiple different <code>Read</code> types</p>



<a name="167795477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795477">(Jun 10 2019 at 20:53)</a>:</h4>
<p>oh, yes, that's true -- but if you have R: Read you can always Box it (though you might end up with multiple levels of boxes, which is unfortunate)</p>



<a name="167795496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795496">(Jun 10 2019 at 20:53)</a>:</h4>
<p>Sure-- the point is that if <code>AsyncRead</code> wasn't object safe, then things like that wouldn't be possible</p>



<a name="167795498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795498">(Jun 10 2019 at 20:53)</a>:</h4>
<p><span class="user-mention" data-user-id="127859">@Taylor Cramer</span> How did that affect runtime performance? I don't know much about Fuchsia's target machines, are they binary-size limited?</p>



<a name="167795499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795499">(Jun 10 2019 at 20:53)</a>:</h4>
<p>Ah, yes, that's true</p>



<a name="167795566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795566">(Jun 10 2019 at 20:54)</a>:</h4>
<p>Though you can sometimes work around it (e.g., create a "fake" object like we do with RawWaker IIRC)</p>



<a name="167795567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795567">(Jun 10 2019 at 20:54)</a>:</h4>
<p>And to be clear, I agree that <code>AsyncRead</code> will ideally be object-safe</p>



<a name="167795582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795582">(Jun 10 2019 at 20:54)</a>:</h4>
<p><span class="user-mention" data-user-id="116155">@Jake Goulding</span> </p>
<blockquote>
<p>I don't know much about Fuchsia's target machines, are they binary-size limited?</p>
</blockquote>
<p>That's not something I can address publicly</p>



<a name="167795597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795597">(Jun 10 2019 at 20:54)</a>:</h4>
<p>I was mostly investigating the "critically important" modifier</p>



<a name="167795611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795611">(Jun 10 2019 at 20:54)</a>:</h4>
<p>Binary size is important</p>



<a name="167795637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795637">(Jun 10 2019 at 20:55)</a>:</h4>
<p>In general sure, cause of cache sizes and all that.</p>



<a name="167795644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795644">(Jun 10 2019 at 20:55)</a>:</h4>
<p>I'd expect that for most things were AsyncRead is worthwhile the async-ness is slow enough that the speed gained by generics would probably not be worth it? i.e., network is too slow</p>



<a name="167795645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795645">(Jun 10 2019 at 20:55)</a>:</h4>
<p>Like I said, I can't speak more specifically</p>



<a name="167795648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795648">(Jun 10 2019 at 20:55)</a>:</h4>
<p>I didn't realize that part wasn't public, I apologize for asking.</p>



<a name="167795665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795665">(Jun 10 2019 at 20:55)</a>:</h4>
<p>no worries! it's an annoying limitation of the world at present :)</p>



<a name="167795735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795735">(Jun 10 2019 at 20:56)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> an interesting point about the expected usecases of the two traits.</p>



<a name="167795761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795761">(Jun 10 2019 at 20:56)</a>:</h4>
<blockquote>
<p>I'd expect that for most things were AsyncRead is worthwhile the async-ness is slow enough that the speed gained by generics would probably not be worth it? i.e., network is too slow</p>
</blockquote>
<p>somewhat, yes, although note that some of these usecases are things like "pipe the data coming from a local socket to stdout"</p>



<a name="167795803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795803">(Jun 10 2019 at 20:57)</a>:</h4>
<p>stdout and such are likely either file i/o or terminal i/o or something like that I suspect so that seems like it'd just support the "don't use generics" argument</p>



<a name="167795897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795897">(Jun 10 2019 at 20:58)</a>:</h4>
<p>at the end of the day I haven't seen very many if any <code>AsyncRead</code> impls that would benefit greatly from being written with <code>async</code>/<code>await</code> such that they would outweigh the rest of these tradeoffs</p>



<a name="167795933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795933">(Jun 10 2019 at 20:58)</a>:</h4>
<p>not including the limitations around what we can actually do with such a type in terms of storing the output future (which is not only nameless, but contains a lifetime parameter that can't be abstracted over due to current limitations of HRTB / GATs)</p>



<a name="167795968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795968">(Jun 10 2019 at 20:59)</a>:</h4>
<p>and I doubt that many people would implement <code>AsyncRead</code> for their own custom types without the help of combinators</p>



<a name="167795987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167795987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167795987">(Jun 10 2019 at 20:59)</a>:</h4>
<p>(it's easy to allow <code>async { ... }</code> implementations of <code>AsyncRead</code> today with an intermediate combinator type)</p>



<a name="167796112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167796112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167796112">(Jun 10 2019 at 21:00)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> yup, they don't need to be crazy fast, but "fast enough" to be useful for things like file transfers</p>



<a name="167796158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167796158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167796158">(Jun 10 2019 at 21:01)</a>:</h4>
<p>sure, where the box probably won't matter I'd guess? i.e., LLVM still sees and optimizes both sides</p>



<a name="167796168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167796168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167796168">(Jun 10 2019 at 21:01)</a>:</h4>
<p>mhm</p>



<a name="167796174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167796174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167796174">(Jun 10 2019 at 21:01)</a>:</h4>
<p>the only problem would be non-buffered file io, but that's slow regardless</p>



<a name="167796239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167796239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167796239">(Jun 10 2019 at 21:02)</a>:</h4>
<p>yeah, we have AsyncBufReader and AsyncBufWriter for that</p>



<a name="167796262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167796262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167796262">(Jun 10 2019 at 21:02)</a>:</h4>
<p>My one gripe/concern with <code>Box&lt;dyn Trait&gt;</code> is that you want to be sure to use it everywhere</p>



<a name="167796306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167796306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167796306">(Jun 10 2019 at 21:03)</a>:</h4>
<p>e.g. you don't want to have crate A which uses it, B which has T: Trait and C which has <code>Box&lt;dyn Trait&gt;</code> in a callchain since you'll end up with <code>Box&lt;Box&lt;dyn Trait&gt;&gt;</code> at the end</p>



<a name="167796327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167796327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167796327">(Jun 10 2019 at 21:03)</a>:</h4>
<p>which is... two levels of pointer chasing?</p>



<a name="167797471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167797471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167797471">(Jun 10 2019 at 21:18)</a>:</h4>
<p>yeah, it'd be great to have specialization around to help solve that one</p>



<a name="167797602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167797602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167797602">(Jun 10 2019 at 21:20)</a>:</h4>
<p>(you sort of want HKT here I think since ideally you'd also not constrain to Box and accept anything "small" but not have to double box and such)</p>



<a name="167797617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167797617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167797617">(Jun 10 2019 at 21:20)</a>:</h4>
<p>though I'm not sure if HKT is the right thing, I'd need to do some more research to be sure.</p>



<a name="167799414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167799414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167799414">(Jun 10 2019 at 21:45)</a>:</h4>
<p><span class="user-mention" data-user-id="116155">@Jake Goulding</span> </p>
<blockquote>
<p>How did that affect runtime performance? </p>
</blockquote>
<p>I realized I didn't address this part of your question-- it didn't at all, but that was particular to the specific place in which the change was made.</p>



<a name="167799425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167799425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167799425">(Jun 10 2019 at 21:45)</a>:</h4>
<p>Other parts of the codebase certainly rely on generics to avoid multiple levels of <code>Box</code>ing</p>



<a name="167799429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167799429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167799429">(Jun 10 2019 at 21:45)</a>:</h4>
<p>which would be performance-critical</p>



<a name="167799483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167799483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167799483">(Jun 10 2019 at 21:46)</a>:</h4>
<p>fwiw you can actually get around the double boxing bit on stable today if your type is 'static via Any</p>



<a name="167816172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167816172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167816172">(Jun 11 2019 at 03:35)</a>:</h4>
<p>Good discussion! I think I might give a +1 to the idea of <span class="user-mention" data-user-id="128448">@stjepang</span> . The naming at least indicates that those are not "real" async types, but all handwritten ones.</p>
<p>I agree that dynamic dispatch would be great to have! I don't have any performance concerns, since I've never experienced any important impact in the past (e.g. comparing boost asio with boxed types vs. templatized ones). The main concern I have is overhead due to dynamic allocations, but trait objects don't necessarily require dynamic allocations.</p>
<p>However if I have to decide between the "being able use trait objects" and "being able to implement types via async functions" I think I would lean towards the latter.</p>



<a name="167816352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167816352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167816352">(Jun 11 2019 at 03:40)</a>:</h4>
<p>I don't agree that one ever wants to implement <code>AsyncRead</code> (or: async byte streams in general) only manually and never through composition.<br>
E.g. in my HTTP/2 library for .NET the Stream implementation (HTTP stream) conforms to a byte stream interface which is basically the equivalent of <code>AsyncRead + AsyncWrite</code>. Reading and writing data is purely implemented in terms of async functions that use async primitives (mutexes, semaphores, internal streams): <a href="https://github.com/Matthias247/http2dotnet/blob/master/Http2/StreamImpl.cs#L371-L480" target="_blank" title="https://github.com/Matthias247/http2dotnet/blob/master/Http2/StreamImpl.cs#L371-L480">https://github.com/Matthias247/http2dotnet/blob/master/Http2/StreamImpl.cs#L371-L480</a></p>
<p>That worked out pretty great, and I wouldn't want to write those things all in a manual fashion.</p>



<a name="167816514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167816514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167816514">(Jun 11 2019 at 03:44)</a>:</h4>
<p>Or as an easier example: The Implementation of an async data pipe, which implements <code>AsyncRead</code> on one end and <code>AsyncWrite</code> on the other. This can be composed on top of a ringbuffer, a synchronous mutex and two async <code>ManualResetEvent</code>s and a two <code>async fns</code>. There is no need to manually touch or store a <code>Waker</code> and to manually implement <code>poll()</code>s</p>



<a name="167816978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167816978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167816978">(Jun 11 2019 at 03:57)</a>:</h4>
<p><span class="user-mention" data-user-id="127859">@Taylor Cramer</span> </p>
<blockquote>
<p>we could do something sorta clever like making the object returned the size of all the arguments to the function + alignment so that you could store them all in a struct and return that type to prevent having to heap-allocate for all the existing impls while retaining object safety</p>
</blockquote>
<p>I like the idea, but I think it can't be done based on the argument alone. The size of the returned <code>Future</code> is determined also be how much state will be on the "stack" of the <code>async fn</code>. And therefore an implementation which uses more "stack" won't fit in the preallocated space for a smaller object. we can probably determine some upper bounds through educated guesses and uses those. Then the functions might return something along <code>FixedBox&lt;Size=256&gt;(dyn Future)</code>. The downside is obviously that large futures won't fit, and for small ones we are wasting space.</p>
<p>Maybe the compiler feature that would help on this is some kind of whole program analysis that inserts at compile-time the actually used number of bytes based on the biggest implementation of the trait that it encountered?</p>
<p>We could also use a box which only allocates dynamically when a given size treshold was exceeded (like <a href="https://docs.rs/smallbox/0.7.3/smallbox/index.html" target="_blank" title="https://docs.rs/smallbox/0.7.3/smallbox/index.html">https://docs.rs/smallbox/0.7.3/smallbox/index.html</a>), but that only seems to make the interface even more restricted and obscure while not solving the general case.</p>



<a name="167868999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/167868999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#167868999">(Jun 11 2019 at 16:59)</a>:</h4>
<blockquote>
<p>the major issue that cramertj mentions is that <code>async fn read</code> in a trait is actually sugar for an associated type + function (well, almost certainly going to be, once it's defined), once you have that associated type on the trait how do you deal with <code>dyn AsyncRead</code>?</p>
</blockquote>
<p>it feels like we need to solve this regardless</p>



<a name="168041774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/168041774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Gilcher <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#168041774">(Jun 13 2019 at 12:57)</a>:</h4>
<p>In general, I agree with <span class="user-mention" data-user-id="127859">@Taylor Cramer</span> that trait objects are often underused, especially at system boundaries.</p>



<a name="168053617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/168053617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Gilcher <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#168053617">(Jun 13 2019 at 15:05)</a>:</h4>
<p>There's another interesting issue that came up yesterday: There's a pretty trivial implementation of <code>Read/Write</code> for <code>AsyncRead/AsyncWrite</code> in futures compat, but it relies on the context being task local and retrievable via <code>Current</code>: <a href="https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.9/futures/compat/struct.Compat.html#impl-Read" target="_blank" title="https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.9/futures/compat/struct.Compat.html#impl-Read">https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.9/futures/compat/struct.Compat.html#impl-Read</a></p>



<a name="168053618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/168053618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Gilcher <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#168053618">(Jun 13 2019 at 15:05)</a>:</h4>
<p>Now, that implementation is quite useful, e.g. to bridge the gap to native-tls and such. Is there a good way to implement this using the new futures?</p>



<a name="168054090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/168054090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#168054090">(Jun 13 2019 at 15:10)</a>:</h4>
<p>Personally I think we need to think about the implicit contexts via compiler/language mechanism, not TLS, that <span class="user-mention" data-user-id="119009">@eddyb</span> and a few others have talked about -- it'd be useful for this sort of "I need global-ish state in a bunch of functions" type thing, such as TyCtxt and Session in the compiler formatting infrastructure etc</p>



<a name="168054105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/168054105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#168054105">(Jun 13 2019 at 15:10)</a>:</h4>
<p>I think I've heard that some language has this? Maybe .. Racket, but not sure</p>



<a name="168058277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/168058277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Gilcher <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#168058277">(Jun 13 2019 at 15:55)</a>:</h4>
<p>Not sure, but I'd actually be interested, as someone who works in fields where "per request" context is a big thing.</p>



<a name="168058354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/168058354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Gilcher <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#168058354">(Jun 13 2019 at 15:56)</a>:</h4>
<p>That's long-term, though, but the question was more if there's a halfway elegant solution with what we have.</p>



<a name="168058914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/168058914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#168058914">(Jun 13 2019 at 16:03)</a>:</h4>
<p><a href="https://github.com/PistonDevelopers/dyon/issues/224" target="_blank" title="https://github.com/PistonDevelopers/dyon/issues/224">https://github.com/PistonDevelopers/dyon/issues/224</a> is basically what I was talking about but I think that's inspired by some other language</p>



<a name="168080327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/168080327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#168080327">(Jun 13 2019 at 20:06)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> my ideas are mostly that of eternaleye, FWIW, so you might want to get a hold of him (are you on IRC? Freenode, specifically)</p>



<a name="168080379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/168080379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#168080379">(Jun 13 2019 at 20:06)</a>:</h4>
<p>I could try to get him in here, hmpf</p>



<a name="168080397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/168080397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#168080397">(Jun 13 2019 at 20:06)</a>:</h4>
<p>Not currently but can be in a week or so (currently in the process of moving, so servers/internet are a bit up in the air)</p>



<a name="168104015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/168104015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#168104015">(Jun 14 2019 at 03:34)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> I think you might be referring to something like implicits in Scala or a language-assisted dependency-injection mechanism in general. For Kotlin this one was recently proposed: <a href="https://github.com/Kotlin/KEEP/blob/46e6a347432d868635e9c6161ca332581315b185/proposals/compile-time-dependency-resolution.md" target="_blank" title="https://github.com/Kotlin/KEEP/blob/46e6a347432d868635e9c6161ca332581315b185/proposals/compile-time-dependency-resolution.md">https://github.com/Kotlin/KEEP/blob/46e6a347432d868635e9c6161ca332581315b185/proposals/compile-time-dependency-resolution.md</a></p>
<p>Dependency injection mechanisms are definitely helpful to cleanup the amount of require boilerplate. However I think of those as mostly a helpful thing and not a must-have. People should be able to write the same code by manually threading through all required arguments too, which involves less magic and has less compatibility issues.</p>



<a name="168136930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/168136930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#168136930">(Jun 14 2019 at 13:56)</a>:</h4>
<p><span class="user-mention" data-user-id="204219">@Matthias247</span> I don't think that's quite the right feature -- and sometimes you can't ergonomically thread the argument through into e.g. a fmt::Display/fmt::Debug impl</p>



<a name="168137028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/168137028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#168137028">(Jun 14 2019 at 13:58)</a>:</h4>
<p>and AIUI this feature would have less overhead than e.g. storing the value in structs since we'd not be using stack space for it -- the compiler would point at some top-level stack frame with the value where it knows a pointer to it or the value itself is</p>



<a name="168148614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/168148614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nemo157 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#168148614">(Jun 14 2019 at 16:09)</a>:</h4>
<p><span class="user-mention" data-user-id="215333">@Florian Gilcher</span> that actually sounds similar to what <a href="https://www.reddit.com/r/rust/comments/c08178/openssl_async_adapter/" target="_blank" title="https://www.reddit.com/r/rust/comments/c08178/openssl_async_adapter/">https://www.reddit.com/r/rust/comments/c08178/openssl_async_adapter/</a> is using</p>



<a name="168148651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/futures%20crate%28s%29/near/168148651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nemo157 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/futures.20crate(s).html#168148651">(Jun 14 2019 at 16:10)</a>:</h4>
<p>But via explicit adaptor fields rather than implicit context</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>